package Cursus.Listeners;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

// Main bij FileListModel.java

public class Test2 extends JFrame {
    static FileListModel flm;

    public Test2() {
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent ww) {
                flm.saveListModelToFile("namen2.txt");
                dispose();
            }
        });
        Container c = this.getContentPane();
        c.setLayout(new FlowLayout());
        flm = new FileListModel("namen.txt");
        JList l = new JList(flm);
        c.add(l);
        flm.addElement("extra tekst");
        flm.addElement("extra tekst2");
    }

    public static void main(String args[]) {
        System.out.println("Starting Test...");
        Test2 mainFrame = new Test2();
        mainFrame.setSize(400, 400);
        mainFrame.setTitle("Test");
        mainFrame.setVisible(true);
    }
}
